package com.mentorgen.tools.profile.instrument.bwfilter;

import com.mentorgen.tools.profile.runtime.EntityDicHelper;
import com.mentorgen.tools.profile.runtime.EntityDictionary;

public class BundleBWFilter extends ClassBandwidthFilterer {

	@Override
	public boolean canFilter() {
		return (EntityDictionary.getBundleDic().size() > 1) ? true : false;
	}

	@Override
	/**
	 * The arguments appear in the following form
	 * @param	arg[0]	the class for the caller method
	 * @param	arg[1]	the class for the callee method
	 */
	public boolean accept(Object... args) {
		
		if (args.length != 2 || !super.allow(args))
			return false;
		
		String loader1 = (String) EntityDictionary.getloaderClassDic().get(
				EntityDicHelper.addClassExtension(((String)args[0]).replaceAll("/", ".")));
		String loader2 = (String) EntityDictionary.getloaderClassDic().get(
				EntityDicHelper.addClassExtension(((String)args[1]).replaceAll("/", ".")));
		
		if (loader1 == null || loader2 == null)
			return false;
		
		return (loader1.equals(loader2)) ? false : true;
	}

}
